//
//  StatusCellBottomView.swift
//  WeiBo_One
//
//  Created by apple on 15/10/27.
//  Copyright © 2015年 蜡笔小炎. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {

    
    //MARK: - 懒加载控件
    // 转发按钮
    private lazy var retweetButton: UIButton = UIButton(title: "转发",
        color: UIColor.lightGrayColor(),
        fontSize: 12,
        backImageName: "timeline_icon_retweet")
    //评论按钮
    private lazy var commentButton: UIButton = UIButton(title: "评论",
        color: UIColor.lightGrayColor(),
        fontSize: 12,
        backImageName: "timeline_icon_comment")
    //点赞按钮
    private lazy var likeButton: UIButton = UIButton(title: "赞",
        color: UIColor.lightGrayColor(),
        fontSize: 12,
        backImageName: "timeline_icon_unlike")
    
    /// 分隔线视图
    private func sepView() -> UIView {
        let v = UIView()
        v.backgroundColor = UIColor.redColor()
        
        return v
    }
    
    //初始化
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
// 设置界面
extension StatusCellBottomView {
    // 界面布局
    private func setupUI() {
        // 背景颜色
        backgroundColor = UIColor(white: 0.95, alpha: 1.0)
        
        //添加控件
        addSubview(retweetButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        //设置布局
        autoSet()
    }
    
    // 自动布局
    private func autoSet() {
        //转发按钮
        retweetButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        //评论按钮
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetButton.snp_top)
            make.left.equalTo(retweetButton.snp_right)
            make.width.equalTo(retweetButton.snp_width)
            make.height.equalTo(retweetButton.snp_height)
        }
        //点赞按钮
        likeButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentButton.snp_top)
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(commentButton.snp_width)
            make.height.equalTo(commentButton.snp_height)
            
            make.right.equalTo(self.snp_right)
        }
        // 分隔线视图
        let sepWidth = 0.5
        let sepScale = 0.4
        // 创建两个分割线视图
        let sep1 = sepView()
        let sep2 = sepView()
        addSubview(sep1)
        addSubview(sep2)
        sep1.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(retweetButton.snp_centerY)
            make.left.equalTo(retweetButton.snp_right)
            make.width.equalTo(sepWidth)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(sepScale)
        }
        sep2.snp_makeConstraints { (make) -> Void in
            make.centerY.equalTo(retweetButton.snp_centerY)
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(sepWidth)
            make.height.equalTo(retweetButton.snp_height).multipliedBy(sepScale)
        }
    }
}
